import { h } from 'vue'
import http from './http'
import iot from './iot'
import system  from './system'


//获取验证码
const queryCaptchaImage=()=>http.get('/captchaImage')

//用户登录校验
const checkUserLogin=(body)=>http.post('/login',body)

//获取登录者信息（含权限信息）
const queryUserProfile=()=>http.get('/getInfo')

//统一管理所有发送请求的方法，暴露出来[按照模块管理]
//获取地图标注数据
const queryDeviceAll=()=>http.get('/iot/device/all')

//获取新闻列表数据
const queryNoticeList=(pageNum=1,pageSize=6)=>{
  return http.get('system/notice/list',{
    params:{
      pageNum,
      pageSize
    }
  })
}
// console.log(queryNoticeList());

//获取设备统计的数据
const  queryDeviceStatistic=()=>http.get('/iot/device/statistic')
//获取饼状图的数据
const queryMonitorServer=()=>http.get('/monitor/server')

//获取Mqtt统计数据
const queryBashBoardStats=()=>http.get('/bashBoard/stats')


//获取产品分类数据 搜索数据
const queryProductList=(obj)=>{
  let {pageNum=1,pageSize=10,categoryName}=obj
  let params={pageNum,pageSize}
  if(categoryName) params.categoryName=categoryName
  return http.get('/iot/category/list',{params})
}

//增加产品分类数据
const queryProductAddList=(categoryName,remark,orderNum)=>http.post('/iot/category',{categoryName,remark,orderNum})

//修改产品分类数据
const queryProductChangeList=(categoryName,remark,orderNum)=>http.put('/iot/category',{categoryName,remark,orderNum})


//获取个人中心数据
const queryProfileData=()=>http.get('/system/user/profile')

//更换头像
const queryAvatarData=(file)=>{
  let fm = new FormData;
  fm.append('file',file);
  return http.post('/system/user/profile/avatar',fm)
}

const  API={
    iot,
    system,
    queryCaptchaImage,
    checkUserLogin,
    queryUserProfile,

    queryDeviceAll,
    queryNoticeList,
    queryDeviceStatistic,
    queryMonitorServer,
    queryBashBoardStats,
    queryProductList,
    queryProductAddList,
    queryProductChangeList,
    queryProfileData,
    queryAvatarData
}
export default API;
